#include "websocketdemo.h"
#include <QPushButton>
#include <QTextEdit>
#include <QFrame>
#include <QVBoxLayout>
#include <QHBoxLayout>

QWebSocketDemo::QWebSocketDemo(QWidget *parent) :
    QDialog(parent)
{
    resize(600,400);
    QHBoxLayout * hboxlayout=new QHBoxLayout;
    QFrame* clientFrame=new QFrame;
    QTextEdit* clientEdit;
    QTextEdit* serverEdit;
    {
        QVBoxLayout* vboxlayout=new QVBoxLayout(clientFrame);
        QPushButton *pushbutton=new QPushButton;
        pushbutton->setText("Start Client");
        connect(pushbutton,SIGNAL(clicked()),this,SLOT(startClient()));
        vboxlayout->addWidget(pushbutton);

        clientEdit=new QTextEdit;
        vboxlayout->addWidget(clientEdit);

    }
    QFrame* serverFrame=new QFrame;
    {
        QVBoxLayout* vboxlayout=new QVBoxLayout(serverFrame);
        QPushButton *pushbutton=new QPushButton;
        pushbutton->setText("Start server");
        connect(pushbutton,SIGNAL(clicked()),this,SLOT(startServer()));
        vboxlayout->addWidget(pushbutton);

        serverEdit=new QTextEdit;
        vboxlayout->addWidget(serverEdit);

    }
    hboxlayout->addWidget(clientFrame);
    hboxlayout->addWidget(serverFrame);
    hboxlayout->setMargin(10);
    hboxlayout->setSpacing(5);
    setLayout(hboxlayout);

}
#include "websocketclient.h"
void QWebSocketDemo::startClient()
{
    WebSocketClient* client=new WebSocketClient(QUrl(QStringLiteral("wss://124.65.181.118:8010/smart")),this);
}

void QWebSocketDemo::startServer()
{

}


void QWebSocketDemo::stopClient()
{
    //wait the thread
}

void QWebSocketDemo::stopServer()
{

}
